import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RestockingPlanSumVO, RestockingPlanSumForm, RestockingPlanSumQuery } from '@/api/plan/restockingPlanSum/types';
import { ParentProductMonthGrossRateForm } from '@/api/performanceTarget/parentProductMonthGrossRate/types';

/**
 * 查询下单计划汇总列表
 * @param query
 * @returns {*}
 */

export const listRestockingPlanSum = (query?: RestockingPlanSumQuery): AxiosPromise<RestockingPlanSumVO[]> => {
  return request({
    url: '/plan/restockingPlanSum/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询下单计划汇总详细
 * @param id
 */
export const getRestockingPlanSum = (id: string | number): AxiosPromise<RestockingPlanSumVO> => {
  return request({
    url: '/plan/restockingPlanSum/' + id,
    method: 'get'
  });
};

/**
 * 新增下单计划汇总
 * @param data
 */
export const addRestockingPlanSum = (data: RestockingPlanSumForm) => {
  return request({
    url: '/plan/restockingPlanSum',
    method: 'post',
    data: data
  });
};

/**
 * 修改下单计划汇总
 * @param data
 */
export const updateRestockingPlanSum = (data: RestockingPlanSumForm) => {
  return request({
    url: '/plan/restockingPlanSum',
    method: 'put',
    data: data
  });
};

/**
 * 删除下单计划汇总
 * @param id
 */
export const delRestockingPlanSum = (id: string | number | Array<string | number>) => {
  return request({
    url: '/plan/restockingPlanSum/' + id,
    method: 'delete'
  });
};

export const sumMonthData = (data?: RestockingPlanSumQuery) => {
  return request({
    url: '/plan/restockingPlanSum/sumMonthData',
    method: 'post',
    data: data
  });
};

export const startPurchase = () => {
  return request({
    url: '/plan/restockingPlanSum/startPurchase',
    method: 'post',
    data: null
  });
};
